<?php get_header(); ?>

<div id="hfeat">

<span class="ht"> Featured Entries </span>

<?php
$gohomecount = get_option('iwatch_gohome');

global $customFields;
$customFields = "'gohome'"; 
$customPosts = new WP_Query();
add_filter('posts_join', 'get_custom_field_posts_join');
add_filter('posts_groupby', 'get_custom_field_posts_group');
$customPosts->query('post_type=any&'.$gohomecount.'' );
remove_filter('posts_join', 'get_custom_field_posts_join');
remove_filter('posts_groupby', 'get_custom_field_posts_group');
while ($customPosts->have_posts()) : $customPosts->the_post();
$links = get_post_custom_values("gohome");
$do_not_duplicate[] = $post->ID; ?> 

<div class="posthome">
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">
<img style="width: 180px; height: 180px;border: 5px ridge #ededed;" src="<?php echo catch_that_image() ?>"/></a>

<div class="htitle"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php if (strlen($post->post_title) > 22) {
echo substr(the_title($before = '', $after = '', FALSE), 0, 22) . '...'; } else {
the_title();
} ?></a></div>

<div class="time"> <?php the_time('F j, Y'); ?> </div>
<div class="com"> <?php comments_popup_link('Add a comment', '1 comment', '% comments'); ?></div>



</div>
	
<?php endwhile; ?> 

</div>

<div id="hrec">

<span class="ht"> Recent Entries </span>

<?php if (have_posts()) : ?>
		<?php while (have_posts()) : the_post();
//if (in_array($post->ID, $do_not_duplicate)) continue;
//if( is_array($do_not_duplicate)){
if(sizeof($do_not_duplicate) > 0 && is_array($do_not_duplicate)){
	if (in_array($post->ID, $do_not_duplicate)) continue;
		update_post_caches($posts);
}
?>


			<div <?php post_class() ?> id="post-<?php the_ID(); ?>">

<div class="posthome">
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">
<img style="width: 180px; height: 180px;border: 5px ridge #ededed;" src="<?php echo catch_that_image() ?>"/></a>

<div class="htitle"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php if (strlen($post->post_title) > 22) {
echo substr(the_title($before = '', $after = '', FALSE), 0, 22) . '...'; } else {
the_title();
} ?></a></div>

<div class="time"> <?php the_time('F j, Y'); ?></div>
<div class="com"> <?php comments_popup_link('Add a comment', '1 comment', '% comments'); ?></div>

</div></div>
	
<?php endwhile; ?><?php else : ?><?php endif; ?>

<div class="navigation">

<?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); } 
			else { ?>

			<div class="alignleft"><?php next_posts_link('&laquo; Older Entries') ?></div>
			<div class="alignright"><?php previous_posts_link('Newer Entries &raquo;') ?></div>
				<?php } ?>

		</div>	

<div id="sidehorz">
<?php include (TEMPLATEPATH . '/twitwdg.php'); ?>
 <?php include(TEMPLATEPATH."/sidebar.php");?>
 <?php include(TEMPLATEPATH."/sidebar2.php");?>
 <?php include(TEMPLATEPATH."/sidebar3.php");?>
</div>

</div>

<?php get_footer(); ?>